package com.prs.crm.dao.archives.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;

import com.prs.crm.dao.archives.ArchivesManagerDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.archives.ArchivesManager;

public class ArchivesManagerDaoImpl extends BaseDaoImpl<ArchivesManager> implements ArchivesManagerDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<ArchivesManager> getAllArchivesManager() {
		Criteria criteria=this.getSession().createCriteria(ArchivesManager.class);
		return criteria.list();
	}

	@Override
	public ArchivesManager getArchivesManager(final String name) {
		Criteria criteria=this.getSession().createCriteria(ArchivesManager.class);
		criteria.add(Restrictions.eq("number", name));
		List result=criteria.list();
		if (result ==null || result.size()==0) {
			return null;
		}
		return (ArchivesManager) criteria.list().get(0);
	}

	@Override
	public ArchivesManager getArchivesManagers(final Integer[] id) {
		Criteria criteria=this.getSession().createCriteria(ArchivesManager.class);
		criteria.add(Restrictions.eq("id", id));
		List result=criteria.list();
		if (result ==null || result.size()==0) {
			return null;
		}
		return (ArchivesManager) criteria.list().get(0);
	}

	@Override
	public ArchivesManager getaArchivesManagers1(final Integer id) {
		Criteria criteria=this.getSession().createCriteria(ArchivesManager.class);
		criteria.add(Restrictions.eq("id", id));
		List result=criteria.list();
		if (result ==null || result.size()==0) {
			return null;
		}
		return (ArchivesManager) criteria.list().get(0);
	}

}
